package com.network.util;

import java.io.IOException;

import com.sun.org.apache.bcel.internal.util.ClassPath;

public final class FilePathUtil
{
	private static ClassPath classPath = new ClassPath(System.getProperty("java.class.path"));

	public static String getAbsolutePath(String fileName) throws IOException
	{
		String absolutePath = "";
		String strTemps[] = fileName.split("[.]");
		if (strTemps.length == 2)
		{
			absolutePath = classPath.getPath(strTemps[0], "." + strTemps[1]);
		}
		else
		{
			throw new IOException("Input File Name not error[" + fileName + "]");
		}
		return absolutePath;
	}
	public static String getRootPath() 
	{
		String absolutePath = "";
		try{
//			this.getClass().getClassLoader().getResource("").getPath(); 
//			absolutePath = (FilePathUtil.class.getClassLoader() +"");//.getPath("lib") +"/";
//			absolutePath = absolutePath.substring(0,absolutePath.lastIndexOf("/")-1 ) ;
//			absolutePath = FilePathUtil.class.getClassLoader().getResource("").getPath()+"/";//.getPath(".").replace("bin", "");
		}
		catch(Exception e){
			e.printStackTrace();
			absolutePath = "";
		}
		
		return absolutePath;
	}
}
